<?php
if (!defined("_INDEX")) { header("Location: /"); die; }

require_once ADMIN.DS."/head.php";
?>
<h1>Список статей</h1><br />
<div class='floating'><a href='tips/add'>Добавить статью</a></div>
<table cellpadding='0' cellspacing='0' class='list'>
	<tr class='table_header'>
		<td width='50px'>ID</td>
		<td width='350px'>Заголовок</td>
		<td width='200px'>Раздел</td>
		<td width='200px' class='actions'>Действия</td>
	</tr><?php
		$query = "select `T`.`title`,`T`.`id`,`S`.`name`
			from `tips` as `T`,`tip_sections` as `S`
			where `T`.`ts_id` = `S`.`id`
			group by `T`.`id`
			order by `T`.`id`";
		$tips = $db->getTable($query);
		foreach ($tips as $tip) {

			echo "<tr width='50px'><td>$tip[id]</td>";
			echo "<td width='350px'>".strip_tags($tip['title'])."</td>";
			echo "<td width='200px'>".strip_tags($tip['name'])."</td>";
			echo "<td width='200px' class='actions'><a href='/admin/tips/edit/{$tip['id']}' class='edit'>Редактировать</a> | <a href='/admin/tips/delete/{$tip['id']}' class='delete'>Удалить</a></td></tr>";
		}
?></table>

<?php require_once ADMIN.DS."/footer.php"; ?>